package customer

import (
	"github.com/gin-gonic/gin"
	"server/api"
	"server/middleware"
)

type CustomerRouter struct{}

func (u *CustomerRouter) InitCustomerRouter(Router *gin.RouterGroup) {
	customerListRouter := Router.Group("customer").Use(middleware.OperationRecord("客户列表"))
	customerEnvRouter := Router.Group("customer").Use(middleware.OperationRecord("环境管理"))
	customerEventRouter := Router.Group("customer").Use(middleware.OperationRecord("事件管理"))
	customerBugRouter := Router.Group("customer").Use(middleware.OperationRecord("漏洞管理"))
	customerFileRouter := Router.Group("customer").Use(middleware.OperationRecord("文件管理"))
	customerPeopleRouter := Router.Group("customer").Use(middleware.OperationRecord("人员管理"))
	customerApi := api.ApiGroupApp.CustomerGroup.CustomerApi
	{
		// 客户列表
		customerListRouter.GET("", customerApi.GetCustomer)
		customerListRouter.POST("", customerApi.AddOrUpdateCustomer)
		customerListRouter.POST("/batch", customerApi.BatchAddOrUpdateCustomer)
		customerListRouter.PUT("", customerApi.AddOrUpdateCustomer)
		customerListRouter.DELETE("/:customerId", customerApi.DeleteCustomer)
		customerListRouter.GET("/all", customerApi.GetAllCustomer)
		// 客户环境
		customerEnvRouter.GET("/env", customerApi.GetCustomerEnv)
		customerEnvRouter.GET("/env/:customerId", customerApi.GetCustomerEnv)
		customerEnvRouter.POST("/env", customerApi.AddOrUpdateCustomerEnv)
		customerEnvRouter.PUT("/env", customerApi.AddOrUpdateCustomerEnv)
		customerEnvRouter.DELETE("/env/:envId", customerApi.DeleteCustomerEnv)
		// 客户事件
		customerEventRouter.GET("/event", customerApi.GetCustomerEvent)
		customerEventRouter.POST("/event", customerApi.AddOrUpdateEvent)
		customerEventRouter.PUT("/event", customerApi.AddOrUpdateEvent)
		customerEventRouter.DELETE("/event/:eventId", customerApi.DeleteEvent)
		// 漏洞管理
		customerBugRouter.GET("/bug", customerApi.GetCustomerBug)
		customerBugRouter.POST("/bug", customerApi.AddOrUpdateBug)
		customerBugRouter.POST("/bug/batch", customerApi.BatchAddBug)
		customerBugRouter.DELETE("/bug/batch", customerApi.BatchDeleteBug)
		customerBugRouter.PUT("/bug", customerApi.AddOrUpdateBug)
		customerBugRouter.PUT("/bugStatus", customerApi.SwitchBugStatus)
		customerBugRouter.DELETE("/bug/:bugId", customerApi.DeleteBug)
		// 文件管理
		customerFileRouter.GET("/file", customerApi.GetCustomerFile)
		customerFileRouter.POST("/file", customerApi.AddOrUpdateFile)
		customerFileRouter.PUT("/file", customerApi.AddOrUpdateFile)
		customerFileRouter.DELETE("/file/:fileId", customerApi.DeleteCustomerFile)
		// 人员管理
		customerPeopleRouter.GET("/people", customerApi.GetPeople)
		customerPeopleRouter.POST("/people", customerApi.AddOrUpdatePeople)
		customerPeopleRouter.PUT("/people", customerApi.AddOrUpdatePeople)
		customerPeopleRouter.DELETE("/people/:peopleId", customerApi.DeletePeople)
		// 客户数据分析
		customerListRouter.GET("/analysis", customerApi.GetCustomerSummary)
		customerListRouter.GET("/envAnalysis", customerApi.GetEnvData)
		customerListRouter.GET("/workOrder", customerApi.GetOnesData)
	}
}
